<script>
import detailCommon from "@/api/ppm/detailCommon.js";
import ppmForm from "@/crm3.0part7-ppm/core/ppmForm.vue";
import conmondt from "@/mixins/order/conmondt.js";
export default {
  name: "ipran10461078",
  mixins: [ppmForm, conmondt],

  created() {
    //明细回显回调函数注册，名称必须固定 add wuyx
    window.initPageOfferDetails = this.initPageOfferDetails;
  },
  mounted() {},

  methods: {
    /**
     * 明细回显回调
     */
    initPageOfferDetails(data) {
      console.log("IPRAN_313_订单送审后");
      console.log("data", data);
      console.log("formData", this.formData);
      this.init(); //初始化方法
      this.contractNumType(this.formData["10461515-142002138"].value); //合同编号类型
      this.yunProvider(this.formData["10461516-142002430"].value); //业务场景
      this.resourcePool(this.formData["10461516-142002269"].value); //资源池类型
      this.IDC(); //是否IDC机房专线
      this.businessType(); // 业务类型
      this.cloudProvider(this.formData["10461516-142002912"].value); //云服务提供商
      this.monthCycle(); //收费周期
      this.feeShow();
    },

    init() {
      //电路标签为普通电路
      if (this.formData["10461521-142002190"].value == "13241001") {
        // this.formData["10461521-142002190"].isshow = false; //电路标签
        this.formData["10461521-142002191"].isshow = false; //电路标签文号
      }
      //订单要求完成日期
      this.SetRequired({
        attrName: "订单要求完成日期",
        formkey: "10461515-100010082",
        reqName: "empty",
        reqStatus: false,
      });
      //产品名称
      this.SetRequired({
        attrName: "产品名称",
        formkey: "10461516-100013399",
        reqName: "empty",
        reqStatus: false,
      });
      //电路维护等级
      this.SetRequired({
        attrName: "电路维护等级",
        formkey: "10461516-100011554",
        reqName: "empty",
        reqStatus: false,
      });
      //速率
      this.SetRequired({
        attrName: "速率",
        formkey: "10461516-100000007",
        reqName: "empty",
        reqStatus: false,
      });
      //是否IDC机房专线
      this.SetRequired({
        attrName: "是否IDC机房专线",
        formkey: "10461516-100012631",
        reqName: "empty",
        reqStatus: false,
      });
      //甲端
      //用户名称
      this.SetRequired({
        attrName: "用户名称",
        formkey: "10461519-100012972",
        reqName: "empty",
        reqStatus: false,
      });
      //手机号码
      this.SetRequired({
        attrName: "手机号码",
        formkey: "10461519-100012981",
        reqName: "empty",
        reqStatus: false,
      });
      //甲端端口类型
      this.SetRequired({
        attrName: "甲端端口类型",
        formkey: "10461519-100013204",
        reqName: "empty",
        reqStatus: false,
      });
      //甲端运营商
      this.SetRequired({
        attrName: "甲端运营商",
        formkey: "10461519-100010765",
        reqName: "empty",
        reqStatus: false,
      });
      //是否汇聚
      this.SetRequired({
        attrName: "是否汇聚",
        formkey: "10461519-142002428",
        reqName: "empty",
        reqStatus: false,
      });
      //乙端
      //用户名称
      this.SetRequired({
        attrName: "用户名称",
        formkey: "10461520-100012972",
        reqName: "empty",
        reqStatus: false,
      });
      //手机号码
      this.SetRequired({
        attrName: "手机号码",
        formkey: "10461520-100012981",
        reqName: "empty",
        reqStatus: false,
      });
      //乙端端口类型
      this.SetRequired({
        attrName: "乙端端口类型",
        formkey: "10461520-100013204",
        reqName: "empty",
        reqStatus: false,
      });
      //乙端运营商
      this.SetRequired({
        attrName: "乙端运营商",
        formkey: "10461520-100010765",
        reqName: "empty",
        reqStatus: false,
      });
      //是否汇聚
      this.SetRequired({
        attrName: "是否汇聚",
        formkey: "10461520-142002428",
        reqName: "empty",
        reqStatus: false,
      });
      //是否与首次月租一起支付
      this.SetRequired({
        attrName: "是否与首次月租一起支付",
        formkey: "10461521-100011646",
        reqName: "empty",
        reqStatus: false,
      });
      //一次性费是否免费
      this.SetRequired({
        attrName: "一次性费是否免费",
        formkey: "10461521-100010009",
        reqName: "empty",
        reqStatus: false,
      });
      //一次性费用收费方式
      this.SetRequired({
        attrName: "一次性费用收费方式",
        formkey: "10461521-100011007",
        reqName: "empty",
        reqStatus: false,
      });
      //收费周期
      this.SetRequired({
        attrName: "收费周期",
        formkey: "10461521-100010009",
        reqName: "empty",
        reqStatus: false,
      });
      //一次性费是否一口价
      this.SetRequired({
        attrName: "一次性费是否一口价",
        formkey: "10461521-100012076",
        reqName: "empty",
        reqStatus: false,
      });
      //一次性费用收款单位
      this.SetRequired({
        attrName: "一次性费用收款单位",
        formkey: "10461522-100013081",
        reqName: "empty",
        reqStatus: false,
      });
      //一次性费用收款单位
      this.SetRequired({
        attrName: "一次性费用收款单位",
        formkey: "10461523-100013081",
        reqName: "empty",
        reqStatus: false,
      });
    },

    //合同编号类型  houbin add
    contractNumType(val) {
      //合同是否为测试合同不为是
      if (val != "142002138004") {
        this.formData["10461516-142002124"].isshow = false; //是否为测试电路 隐藏
      }
    },

    //业务场景  houbin add
    yunProvider(val) {
      //云网融合型
      if (val == "227900002") {
        if (
          //阿里云、腾讯云、华为云、微软云、AWS、上海自有云（CLSN）、百度云、UCloud
          this.formData["10461516-142002912"].value == "22113552602" ||
          this.formData["10461516-142002912"].value == "22113552603" ||
          this.formData["10461516-142002912"].value == "22113552604" ||
          this.formData["10461516-142002912"].value == "22113552605" ||
          this.formData["10461516-142002912"].value == "22113552606" ||
          this.formData["10461516-142002912"].value == "22113552607" ||
          this.formData["10461516-142002912"].value == "22113552608" ||
          this.formData["10461516-142002912"].value == "22113552609"
        ) {
          this.formData["10461516-142002269"].isshow = false; //资源池类型 隐藏
        }
        //非普通组网时隐藏
        this.formData["10461519-100013021"].isshow = false; //乙端装机地址 隐藏
        this.formData["10461519-100012972"].isshow = false; //乙端用户名称 隐藏
        this.formData["10461519-142002911"].isshow = false; //甲端 是否需要U设备
        this.SetRequired({
          attrName: "是否需要U设备",
          formkey: "10461519-142002911",
          reqName: "empty",
          reqStatus: false,
        }); //甲端 是否需要U设备 非必填
        this.formData["10461520-142002911"].isshow = false; //乙端 是否需要U设备
        this.SetRequired({
          attrName: "是否需要U设备",
          formkey: "10461520-142002911",
          reqName: "empty",
          reqStatus: false,
        }); //乙端 是否需要U设备 非必填
      } else {
        //普通组网
        this.formData["10461516-142002912"].isshow = false; //云服务提供商 隐藏
        this.formData["10461516-142001052"].isshow = false; //云资源池站点 隐藏
        this.formData["10461516-142001053"].isshow = false; //CTYUN账号 隐藏
        this.formData["10461516-142002269"].isshow = false; //资源池类型 隐藏
        this.formData["10461516-142002011"].isshow = false; //本端VPC ID 隐藏
        this.formData["10461516-142002152"].isshow = false; //本端VPC ID网段/掩码  隐藏
        this.formData["10461516-142002013"].isshow = false; //客户侧互联地址/掩码 隐藏
        this.formData["10461516-142002014"].isshow = false; //云侧互联地址/掩码 隐藏
        this.formData["10461516-100011674"].isshow = false; //客户侧网段/掩码 隐藏
        this.formData["10461519-142002911"].isshow = true; //甲端 是否需要U设备
        this.SetRequired({
          attrName: "是否需要U设备",
          formkey: "10461519-142002911",
          reqName: "empty",
          reqStatus: true,
        }); //甲端 是否需要U设备 必填
        this.formData["10461520-142002911"].isshow = false; //乙端 是否需要U设备
        this.SetRequired({
          attrName: "是否需要U设备",
          formkey: "10461520-142002911",
          reqName: "empty",
          reqStatus: false,
        }); //乙端 是否需要U设备 非必填
      }
    },

    //资源池类型  houbin add
    resourcePool(val) {
      //不为专属云时
      if (val != "2019072002") {
        this.formData["10461516-142002189"].isshow = false; //专属云ID 隐藏
        this.formData["10461516-142002183"].isshow = false; //专属云名称 隐藏
      }
    },

    //是否IDC机房专线  houbin add
    IDC() {
      if (this.formData["10461516-100012631"].value == "1") {
        this.formData["10461516-142002498"].isshow = true; //机房专线类型
        this.SetRequired({
          attrName: "机房专线类型",
          formkey: "10461516-142002498",
          reqName: "empty",
          reqStatus: true,
        }); //机房专线类型 必填
      } else {
        this.formData["10461516-142002498"].isshow = false; //机房专线类型 隐藏
        this.SetRequired({
          attrName: "机房专线类型",
          formkey: "10461516-142002498",
          reqName: "empty",
          reqStatus: false,
        }); //机房专线类型 非必填
        this.formData["10461516-142002498"].value = ""; //机房专线类型 清空
      }
      this.comLine();
    },

    //机房专线类型  houbin add
    comLine() {
      this.formData["10461516-142002499"].isshow = false; //甲端机房编码、
      this.formData["10461516-100011034"].isshow = false; //乙端机房编码
      if (this.formData["10461516-142002498"].value == "2468001") {
        this.formData["10461516-142002499"].isshow = true; //甲端机房编码
      } else if (this.formData["10461516-142002498"].value == "2468002") {
        this.formData["10461516-100011034"].isshow = true; //乙端机房编码
      } else if (this.formData["10461516-142002498"].value == "2468003") {
        this.formData["10461516-142002499"].isshow = true; //甲端机房编码
        this.formData["10461516-100011034"].isshow = true; //乙端机房编码
      }
    },

    //MTU数值
    mtuNumber(val) {
      let check = /^[1-9]\d*$/;
      if (check.test(val)) {
        if (val > 9600 || val < 1518) {
          this.$alert("只能填写1518~9600之间的正整数!", "提示", {
            type: "warning",
            confirmButtonText: "关闭",
          });
          this.formData["10461516-141000144"].value = "";
        }
      } else {
        this.$alert("只能填写1518~9600之间的正整数!", "提示", {
          type: "warning",
          confirmButtonText: "关闭",
        });
        this.formData["10461516-141000144"].value = "";
      }
    },

    //IPRAN暂时屏蔽“点到多点”，后端不支撑
    businessType() {
      //点到多点
      if (this.formData["10461516-100001004"].value == "88800130002") {
        this.formData["10461519-142002428"].isshow = true; //甲端是否汇聚主点 展示
        this.SetRequired({
          attrName: "是否汇聚主点",
          formkey: "10461519-142002428",
          reqName: "empty",
          reqStatus: true,
        }); //甲端是否汇聚主点 必填
        this.formData["10461520-142002428"].isshow = true; //乙端是否汇聚主点 展示
        this.SetRequired({
          attrName: "是否汇聚主点",
          formkey: "10461520-142002428",
          reqName: "empty",
          reqStatus: true,
        }); //乙端是否汇聚主点 必填
        this.formData["10461519-142002908"].isshow = true; //汇聚组号
        this.formData["10461520-142002908"].isshow = true;
        this.formData["10461519-142002910"].isshow = true; //汇聚同组电路数
        this.formData["10461520-142002910"].isshow = true;
      } else {
        //点到点
        this.formData["10461519-142002428"].isshow = false; //甲端是否汇聚主点 隐藏
        this.formData["10461519-142002428"].value = ""; //甲端是否汇聚主点 清空
        this.SetRequired({
          attrName: "是否汇聚主点",
          formkey: "10461519-142002428",
          reqName: "empty",
          reqStatus: false,
        }); //甲端是否汇聚主点 非必填
        this.formData["10461520-142002428"].isshow = false; //乙端是否汇聚主点 隐藏
        this.formData["10461520-142002428"].value = ""; //甲端是否汇聚主点 清空
        this.SetRequired({
          attrName: "是否汇聚主点",
          formkey: "10461520-142002428",
          reqName: "empty",
          reqStatus: false,
        }); //乙端是否汇聚主点 非必填
        this.formData["10461519-142002908"].isshow = false; //甲端汇聚组号
        this.formData["10461519-142002908"].value = "";
        this.formData["10461520-142002908"].isshow = false; //乙端汇聚组号
        this.formData["10461520-142002908"].value = "";
        this.formData["10461519-142002910"].isshow = false; //甲端汇聚同组电路数
        this.formData["10461519-142002910"].value = "";
        this.formData["10461520-142002910"].isshow = false; //乙端汇聚同组电路数
        this.formData["10461520-142002910"].value = "";
      }
      this.collectA(this.formData["10461519-142002428"].value); //甲端是否汇聚
      this.collectB(this.formData["10461520-142002428"].value); //乙端是否汇聚
    },

    collectA(val) {
      //甲端是否汇聚
      //点到多点
      if (
        val == "2" &&
        this.formData["10461520-142002428"].value == "2" &&
        this.formData["10461516-100001004"].value == "88800130002"
      ) {
        this.$message({
          message: "甲端乙端是否汇聚不可以同时选否",
          showClose: true,
        });
        this.formData["10461520-142002428"].value = "";
      }
      if (val == "1") {
        this.formData["10461519-142002417"].isshow = true;
        this.SetRequired({
          attrName: "汇聚类型",
          formkey: "10461519-142002417",
          reqName: "empty",
          reqStatus: true,
        }); //甲端汇聚类型 必填
        this.formData["10461519-142002416"].isshow = true;
        this.SetRequired({
          attrName: "汇聚VLAN序号/时隙号",
          formkey: "10461519-142002416",
          reqName: "empty",
          reqStatus: true,
        }); //甲端汇聚VLAN序号/时隙号 必填
      } else {
        this.formData["10461519-142002417"].isshow = false;
        this.formData["10461519-142002417"].value = "";
        this.SetRequired({
          attrName: "汇聚类型",
          formkey: "10461519-142002417",
          reqName: "empty",
          reqStatus: false,
        }); //甲端汇聚类型 非必填
        this.formData["10461519-142002416"].isshow = false;
        this.formData["10461519-142002416"].value = "";
        this.SetRequired({
          attrName: "汇聚VLAN序号/时隙号",
          formkey: "10461519-142002416",
          reqName: "empty",
          reqStatus: false,
        }); //甲端汇聚VLAN序号/时隙号 非必填
      }
      this.collectTypeA(this.formData["10461519-142002417"].value); //甲端汇聚类型
    },

    collectB(val) {
      //乙端是否汇聚
      if (
        val == "2" &&
        this.formData["10461519-142002428"].value == "2" &&
        this.formData["10461516-100001004"].value == "88800130002"
      ) {
        this.$message({
          message: "甲端乙端是否汇聚不可以同时选否",
          showClose: true,
        });
        this.formData["10461519-142002428"].value = "";
        // val=1
      }
      if (val == "1") {
        this.formData["10461520-142002417"].isshow = true;
        this.SetRequired({
          attrName: "汇聚类型",
          formkey: "10461520-142002417",
          reqName: "empty",
          reqStatus: true,
        }); //乙端汇聚类型 必填
        this.formData["10461520-142002416"].isshow = true;
        this.SetRequired({
          attrName: "汇聚VLAN序号/时隙号",
          formkey: "10461520-142002416",
          reqName: "empty",
          reqStatus: true,
        }); //汇聚VLAN序号/时隙号 必填
      } else {
        this.formData["10461520-142002417"].isshow = false;
        this.formData["10461520-142002417"].value = "";
        this.SetRequired({
          attrName: "汇聚类型",
          formkey: "10461520-142002417",
          reqName: "empty",
          reqStatus: false,
        }); //乙端汇聚类型 非必填
        this.formData["10461520-142002416"].isshow = false;
        this.formData["10461520-142002416"].value = "";
        this.SetRequired({
          attrName: "汇聚VLAN序号/时隙号",
          formkey: "10461520-142002416",
          reqName: "empty",
          reqStatus: false,
        }); //乙端汇聚VLAN序号/时隙号 非必填
      }
      this.collectTypeB(this.formData["10461520-142002418"].value); //乙端汇聚类型
    },

    collectTypeA(val) {
      //甲端汇聚类型
      if (val == "80060008002") {
        this.SetRequired({
          attrName: "汇聚参考接入电路代号",
          formkey: "10461519-142002418",
          reqName: "empty",
          reqStatus: true,
        });
      } else {
        this.SetRequired({
          attrName: "汇聚参考接入电路代号",
          formkey: "10461519-142002418",
          reqName: "empty",
          reqStatus: false,
        });
      }
    },

    collectTypeB(val) {
      //乙端汇聚类型
      if (val == "80060008002") {
        this.SetRequired({
          attrName: "汇聚参考接入电路代号",
          formkey: "10461520-142002418",
          reqName: "empty",
          reqStatus: true,
        });
      } else {
        this.SetRequired({
          attrName: "汇聚参考接入电路代号",
          formkey: "10461520-142002418",
          reqName: "empty",
          reqStatus: false,
        });
      }
    },

    //云服务提供商 houbin add
    cloudProvider(val) {
      if (val != "22113552601") {
        //不为天翼云
        this.formData["10461521-142003015"].isshow = true; //多云接入端口月使用费
        this.formData["10461521-100010007"].isshow = true; //多云接入端口收款单位
        this.formData["10461521-100010008"].isshow = true; //多云接入端口委托收款单位
        this.formData["10461521-100011056"].isshow = true; //多云接入端口币种
      } else {
        this.formData["10461521-142003015"].isshow = false; //多云接入端口月使用费
        this.formData["10461521-100010007"].isshow = false; //多云接入端口收款单位
        this.formData["10461521-100010008"].isshow = false; //多云接入端口委托收款单位
        this.formData["10461521-100011056"].isshow = false; //多云接入端口币种
      }
    },

    //收费周期  houbin add
    monthCycle() {
      if (this.formData["10461521-100010009"].value == "80050019028") {
        this.formData["10461521-142001024"].isshow = true; //预收月数
        this.SetRequired({
          attrName: "预收月数",
          formkey: "10461521-142001024",
          reqName: "empty",
          reqStatus: true,
        }); //预收月数 必填
      } else {
        this.formData["10461521-142001024"].isshow = false; //预收月数
        this.SetRequired({
          attrName: "预收月数",
          formkey: "10461521-142001024",
          reqName: "empty",
          reqStatus: false,
        }); //预收月数 非必填
      }
    },

    /**
     * 设备产商弹窗选中回调方法，回显设备型号、主控板软件版本
     */
    getInputGridValue(obj) {
      let key = obj["key"];
      let optionItem = this.formData[key];
      let itemDevType = detailCommon.getItemByAttrIdRolcd(
        "100013577",
        optionItem.attrRoleCd,
        this.formData
      );
      let itemSoftVersion = detailCommon.getItemByAttrIdRolcd(
        "100012654",
        optionItem.attrRoleCd,
        this.formData
      );
      detailCommon.setItemVal(itemDevType, obj.data.devType);
      detailCommon.setItemVal(itemSoftVersion, obj.data.softVersion);
    },

    feeShow() {
      let handleStateCd = JSON.parse(
        sessionStorage.getItem("changeRow")
      ).handleStateCd;
      //订单起一次费可改 需求单起送审核前一次费不可改
      if (handleStateCd == "50030002") {
        this.formData["10461521-100011646"].disabled = true; //是否与首次月租一起支付
        this.formData["10461521-141000009"].disabled = true; //一次性费是否免费
        this.formData["10461521-100011007"].disabled = true; //一次性费用收费方式
        this.formData["10461522-100010651"].disabled = true; //一次性费用币种
        this.formData["10461522-100012523"].disabled = true; //调测费
        this.formData["10461522-100013081"].disabled = true; //一次性费用收款单位
        this.formData["10461522-100013366"].disabled = true; //一次性委托收款单位
        this.formData["10461523-100010651"].disabled = true; //一次性费用币种
        this.formData["10461523-100012523"].disabled = true; //调测费
        this.formData["10461523-100013081"].disabled = true; //一次性费用收款单位
        this.formData["10461523-100013366"].disabled = true; //一次性委托收款单位
      }
    },
  },
};
</script>
